Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SELinux Check #386

Closed

Conversation

Mashimiao
Copy link

  1. update godeps and add go-selinux deps
  2. add selinux check in validate and runtimetest

return fmt.Errorf("Failed to get mountLabel of %v", mount.Destination)
}
if fileLabel != spec.Linux.MountLabel {
return fmt.Errorf("Expected mountLabel %v, actual %v", spec.Linux.MountLabel, fileLabel)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no RFC 2119 requirements for the runtime for linux.mountLabel. I think we need to get spec language about what the runtime MUST do before we can fail a runtime for not doing it (opencontainers/runtime-spec#746).

@@ -519,6 +520,12 @@ func (v *Validator) CheckLinux() (msgs []string) {
}
}

if v.spec.Linux.MountLabel != "" {
if err := label.Validate(v.spec.Linux.MountLabel); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what label.Validate is checking, but the spec places no limits on the linux.mountLabel value. If we want to validate it (against a particular kernel API?), then I think we probably need clarity in the spec about what API the value will be passed to, and the check here should probably only happen when HostSpecific is set.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation of mountLabel is not host-specific. It just checks whether label contains unexpected options. Please refer to label.Validate()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just checks whether label contains unexpected options.

But there is nothing in the spec about “MUST be a valid SELinux label according to [some SELinux spec]” or “MUST NOT contain z or Z” or anything like that. Currently spec-readers have to make that jump on their own.

And I was suggesting host-specific because even if z and Z are not legal labels for today's kernel, are we sure that they will be illegal labels for all kernels? Maybe someone compiles a Linux kernel where they are legal, and the spec's kernel-punt-where-possible approach is designed to support that sort of thing.

Copy link
Contributor

@wking wking Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't see spec grounds for this check, but if the runtime-tools maintainers feel like it's grounded (or if they just want “unlikely to be supported by the kernel” warnings), then the validate/ changes from this PR belong in v0.3.0. That could either happen by spinning them out into a new PR, or by reviewing them here in the context of the runtimetest changes.

@zhouhao3
Copy link

zhouhao3 commented Jul 28, 2017

LGTM

Approved with PullApprove

Ma Shimiao added 2 commits November 22, 2017 14:57
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
if err != nil {
return fmt.Errorf("Failed to get mountLabel of %v", mount.Destination)
}
if fileLabel != spec.Linux.MountLabel {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux judgment should be increased to avoid panic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
@zhouhao3
Copy link

zhouhao3 commented Nov 23, 2017

LGTM

Approved with PullApprove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants